16 |
17 |
22 |
23 | @foreach (var element in VisibleElements )
24 | {
25 |
29 |
30 | }
31 |
32 |
33 |
34 |
35 | #BLAGARIO
36 |
37 |
38 |
39 |
40 |
41 | @foreach( var cell in Universe.World.Leaderboard)
42 | {
43 | - @cell.Name @cell.Mass.ToString()
44 | }
45 |
46 |
47 |
48 |
49 | @if ( Player.Cell.IsDead )
50 | {
51 |
52 |
53 |
54 |
55 | }
56 |
57 |
58 |
--------------------------------------------------------------------------------
/src/blagario/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
3 | }
4 |
5 | .universe {
6 | position: fixed;
7 | background-color: rgb(15, 90, 15);
8 | margin: 0;
9 | padding: 0;
10 | border: 0;
11 | }
12 |
13 | .scoreboard {
14 | position: fixed;
15 | background-color: rgba(0, 0, 0, 0.507);
16 | margin: 0;
17 | padding: 0;
18 | border: 1px solid rgba(255, 0, 0, 0.555);
19 | top: 10px;
20 | left: 10px;
21 | width: 100px;
22 | height: 40px;
23 | }
24 |
25 | .world {
26 | position: fixed;
27 | background-color: black;
28 | margin: 0;
29 | padding: 0;
30 | border: 1px solid red;
31 | }
32 |
33 | .agar-element {
34 | position: absolute;
35 | border-radius: 50%;
36 | background-color: orange;
37 | margin: 0;
38 | padding: 0;
39 | border: 0;
40 | }
41 |
42 | .cellpart {
43 | position: fixed;
44 | border-radius: 50%;
45 | background-color: orange;
46 | margin: 0;
47 | padding: 0;
48 | border: 0;
49 | }
50 |
51 | .virus {
52 | position: absolute;
53 | border-radius: 50%;
54 | width: 100px;
55 | height: 100px;
56 | background: rgba(0, 128, 0, 0.671);
57 | margin: 0;
58 | padding: 0;
59 | border: 0;
60 | }
61 |
62 | .pellet {
63 | position: absolute;
64 | border-radius: 50%;
65 | width: 1px;
66 | height: 1px;
67 | background: green;
68 | margin: 0;
69 | padding: 0;
70 | border: 0;
71 | }
72 |
73 | .leaderboard {
74 | position: fixed;
75 | background-color:#00000081;
76 | margin: 0;
77 | padding: 0;
78 | border: 1px solid rgba(255, 0, 0, 0.644);
79 | width: 200px;
80 | top: 10px;
81 | right: 10px;
82 | height: 300px;
83 | }
84 |
85 | .leaderboard ul {
86 | padding: 14px;
87 | margin: 0;
88 | color: white;
89 | }
90 |
91 | .respawn {
92 | position: fixed;
93 | top: 50%;
94 | left: 50%;
95 | }
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/src/blagario/AgarElements/AgarElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 |
4 | namespace blagario.elements
5 | {
6 | public enum ElementType
7 | {
8 | Universe,
9 | World,
10 | Virus,
11 | Pellet,
12 | CellPart,
13 | W
14 | }
15 | public class AgarElement
16 | {
17 | protected static readonly Random getrandom = new Random();
18 | private Guid key = Guid.NewGuid();
19 | public string Key => key.ToString();
20 | public ElementType ElementType {get; protected set; }
21 | public string Name {get; set;} = "";
22 | public double X {set; get; }
23 | public double Y {set; get; }
24 | public double _Mass {set; get; }
25 | public double _EatedMass {set; get; } = 0;
26 | public virtual bool EatableByMySelf {set; get; } = false;
27 | public long Mass => (int)_Mass;
28 | public virtual long MaxMass {set; get; } = 20000;
29 | public virtual async Task Tic(int fpsTicNum)
30 | {
31 | double eat = 0;
32 | if ( _EatedMass>0 )
33 | {
34 | eat = _Mass * 0.01;
35 | eat = (eat>_EatedMass) ? _EatedMass : eat;
36 | }
37 |
38 | _EatedMass -= eat;
39 | _Mass += eat;
40 | await Task.CompletedTask;
41 | }
42 | public virtual double Radius => ElementsHelper.GetRadiusFromMass(this.Mass);
43 |
44 | public virtual double Diameter => Radius * 2;
45 | public long CssX =>ElementsHelper.TryConvert(X-Radius);
46 | public long CssY =>ElementsHelper.TryConvert(Y-Radius);
47 | public Universe Universe {get; protected set;}
48 | public string CssClass => this.GetType().Name.ToLower();
49 | public virtual string CssStyle( Player c) => $@"
50 | top: {(c.YGame2World(CssY)).ToString()}px ;
51 | left: {(c.XGame2World(CssX)).ToString()}px ;
52 | width: {(ElementsHelper.TryConvert(Diameter * c.Zoom)).ToString()}px ;
53 | height: {(ElementsHelper.TryConvert(Diameter * c.Zoom)).ToString()}px ;
54 | ";
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/blagario/AgarElements/Cell.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace blagario.elements
6 | {
7 | public class Cell: List